<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Gifter</title>
    <meta name="WTF to give your friends" content="">
    <meta name="GreatWhiteNerds" content="">

    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
    <!--if lt IE 9>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <endif -->

    <!-- Le styles -->
    <link href="/stylesheets/bootstrap.css" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 60px;
      }
    </style>
	<script src="script/json2.js"></script>
  	<script src="http://code.jquery.com/jquery-latest.js"></script>
	<script src="script/underscore-1.1.6.js"></script>
	<script src="script/backbone.js"></script>
	<script src="script/backbone-localstorage.js"></script>
	<script src="script/friends.js"></script>
  </head>

  <body>

    <div class="topbar">
      <div class="fill">
        <div class="container">
			<a class="brand" href="#">Gifter</a>
          <ul class="nav"> <li class="active"><a href="#">Home</a></li> 
			 <li><a href="#about">About</a></li> 
			 <li><a href="#contact">Contact</a></li>
			 </ul>
        </div>
      </div>
    </div>

    <div class="container">

      <!-- Main hero unit for a primary marketing message or call to action -->
      <div class="hero-unit">
        <h1>Gifter</h1>

        <p>Vestibulum id ligula porta felis euismod semper. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.</p>
        <p><a class="btn primary large" href="/jsonTest">Learn more &raquo;</a></p>

		<button class="btn primary large" id="fb-auth">Authenticate with Facebook</button>
		<div class="friends-block"></div>
		<script>
		function displayUser(user) {
       var userName = document.getElementById('userName');
       var greetingText = document.createTextNode('Greetings, '
         + user.name + '.');
   userName.appendChild(greetingText);
    var accessToken = window.location.hash.substring(1);
       var path = "https://graph.facebook.com/me/friends?";
   var queryParams = [accessToken, 'callback=displayFriends'];
   var query = queryParams.join('&');
   var url = path + query;

   // use jsonp to call the graph
       var script = document.createElement('script');
       script.src = url;
       document.body.appendChild(script);   
     }
	  function displayFriends(friendsList) {
		friends.appendChild(friendsList.data[0].name);	
	  }


			$("#fb-auth").click(function() {
          var appID = "275948332451573";
     if (window.location.hash.length == 0) {
       var path = 'https://www.facebook.com/dialog/oauth?';
   var queryParams = ['client_id=' + appID,
     'redirect_uri=' + window.location,
     'response_type=token'];
   var query = queryParams.join('&');
   var url = path + query;
   window.open(url);
     } else {
       var accessToken = window.location.hash.substring(1);
       var path = "https://graph.facebook.com/me?";
   var queryParams = [accessToken, 'callback=displayUser'];
   var query = queryParams.join('&');
   var url = path + query;

   // use jsonp to call the graph
       var script = document.createElement('script');
       script.src = url;
       document.body.appendChild(script);        
     }
 });

 function onClick() {
	 $.ajax({
		 url: "/ebay?suggestions=jeans&minprice=0&maxprice=100&results=20",
		 cache: false,
		 success: function(html) {
			 $("#results").html(html);
		 }
	 });
 }
   </script> 
   <button onclick="onClick();" class="btn primary large">Populate Suggestions</button>
   <p id="userName"></p> 
	<p id="friends"></p>
	<p id="results"></p>
      </div>



      <!-- Example row of columns -->
      <div class="row">
        <div id="friends-div" class="span-one-third">
          <h2>Friends</h2>
          <ul id="friends-list"></ul>
        </div>
        
		  
		  
		  
		  
		  
		  <div class="span-one-third">
          <h2>Heading</h2>
           <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn" href="#">View details &raquo;</a></p>
       </div>
        <div class="span-one-third">
          <h2>Heading</h2>
          <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
          <p><a class="btn" href="#">View details &raquo;</a></p>
        </div>
      </div>

      <footer>
        <p>&copy; Company 2011</p>
      </footer>

    </div> <!-- /container -->

<!-- Templates -->

<script type="text/template" id="friend-template">
	<div class="friend">
		<div class="display">
			<div class="friend-name"></div>
			<div class="friend-gift"></div>
		</div>
	</div>
</script>


  </body>
</html>
